package mark.tom.index.facade.enums;

public enum IndexType {

    ACTIVITY(0, "android.app.Activity"),
    SERVICE(1, "android.app.Service"),
    FRAGMENT(2, "android.app.Fragment"),
    PROVIDER(3, "com.alibaba.android.arouter.facade.template.IProvider"),
    HOLDER(4, "com.alibaba.android.arouter.facade.template.IViewHolder"),
    UNKNOWN(-1, "Unknown route type");

    int id;
    String className;

    IndexType(int id, String className) {
        this.id = id;
        this.className = className;
    }

    public int getId() {
        return id;
    }

    public String getClassName() {
        return className;
    }

    public IndexType setId(int id) {
        this.id = id;
        return this;
    }

    public IndexType setClassName(String className) {
        this.className = className;
        return this;
    }

    public static IndexType parse(String name) {
        for (IndexType routeType : IndexType.values()) {
            if (routeType.getClassName().equals(name)) {
                return routeType;
            }
        }
        return UNKNOWN;
    }
}
